//
//  SetValue.m
//  ShowWebView
//
//  Created by hjj on 13-3-7.
//  Copyright (c) 2013年 hjj. All rights reserved.
//

#import "SetValue.h"

@implementation SetValue

+(NSString *)GetJSValueByID:(NSString *)id_name andtype:(NSString *)id_type andValue:(NSString *)id_value
{NSString *htmlStr = id_value;
    htmlStr = [htmlStr stringByReplacingOccurrencesOfString:@"\r\n" withString:@""];
    htmlStr = [htmlStr stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    htmlStr = [htmlStr stringByReplacingOccurrencesOfString:@"\'" withString:@"\\'"];
    htmlStr = [htmlStr stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
    NSString *str = [NSString stringWithFormat:@"var field = document.getElementById('%@'); field.%@='%@';",id_name,id_type,htmlStr];
    return str;
}
+(NSString *)GetJSAddValueByID:(NSString *)id_name andtype:(NSString *)id_type andValue:(NSString *)id_value
{NSString *htmlStr = id_value;
    htmlStr = [htmlStr stringByReplacingOccurrencesOfString:@"\r\n" withString:@""];
    htmlStr = [htmlStr stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    htmlStr = [htmlStr stringByReplacingOccurrencesOfString:@"\'" withString:@"\\'"];
    htmlStr = [htmlStr stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
    NSString *str = [NSString stringWithFormat:@"var field = document.getElementById('%@'); field.%@+='%@';",id_name,id_type,htmlStr];
    return str;
}

@end
